<?php
  /**
   * This class provides static methods to access and modify the $_POST variable
   * It is recommended to used this instead of accessing the $_POST variable directly
   *
   * @author Macdonald Terrence Robinson
   * @package Core
   *
   */
  final class Post
  {
    public static function init()
    {
      if( !isset($_POST) )
        $_POST = array();
    }
    
    public static function getByKey($keyName)
    {
      if(isset($_POST[$keyName]))
        return trim($_POST[$keyName]);
        
      return NULL;
    }

    public static function set($keyName, $keyValue)
    {
      $_POST[$keyName] =  $keyValue;
    }

    public static function remove($keyName)
    {
      if( self::isExists($keyName) )
        unset($array[$keyName]);
    }

    public static function rename($key, $newKey)
    {
      $tmp = $_POST[$keyName];
      unset($_POST[$keyName]);
      self::set($newKey, $tmp);
    }

    public static function setAll(array $newArray)
    {
      $_POST = $newArray;
    }

    public static function clear()
    {
      $_POST = array();
    }

    public static function isExists($key)
    {
      if(isset($_POST[$key]))
        return true;
      else
        return false;
    }
    
    public static function getAll()
    {
      return $_POST;
    }
  }
?>
